const fs = require('fs')
const path = require('path')

function news(){
    const data = fs.readFileSync(path.join(__dirname,'./data/news.json'),'utf-8')
    return JSON.parse(data)
} 
function students(){
    const data = fs.readFileSync(path.join(__dirname,'./data/info.json'),'utf-8')
    return JSON.parse(data)
}
function lucystar(){
    let list = students()
    let num = Math.floor(Math.random()*list.length)
    list[num].count++
    fs.writeFileSync(path.join(__dirname,'./data/info.json'),JSON.stringify(list))
    return list[num]
}
module.exports = {
    news,
    students,
    lucystar
}